<template>
  <div class="department_add">
    <div class="department_box">
      <el-form :model="form" label-width="120px">
        <el-form-item label="科室名称">
          <el-input
            v-model="form.name"
            placeholder="请输入科室名称"
            clearable
          />
        </el-form-item>
        <el-form-item label="科室主任">
          <el-input
            v-model="form.maindoctor"
            placeholder="请输入科室主任"
            clearable
          />
        </el-form-item>
        <el-form-item label="科室编号">
          <el-input v-model="form.id" placeholder="" disabled />
        </el-form-item>
        <el-form-item label="创建时间">
          <el-input v-model="form.time" placeholder="" disabled />
        </el-form-item>
        <el-form-item label="">
          <el-button type="primary" @click="onSubmit">确认创建</el-button>
          <el-button type="info">返回上一级</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref } from "vue";
import { departmentAddReq } from "@/api/department.api";
import { ElMessage } from "element-plus";
const form = reactive({
  name: "",
  maindoctor: "",
  id: "系统自动生成",
  time: "系统自动生成",
});
// 点击创建
const onSubmit = async () => {
  if (form.name == "" || form.maindoctor == "") {
    ElMessage.error("请将信息填写完整！");
    return;
  }
  const res = await departmentAddReq(form);
  console.log(res, "9999");
  if (res.data.code == 1) {
    ElMessage({
      message: res.data.msg,
      type: "success",
    });
    form.name = "";
    form.maindoctor = "";
  } else {
    ElMessage.error(res.data.msg);
  }
};
</script>

<style scoped lang="scss">
.department_add {
  width: 100%;
  height: 100%;
  .department_box {
    width: 500px;
    height: 100%;
  }
}
</style>
